package com.jia.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jia.product.entity.AttrAttrGroupRelation;
import com.jia.product.mapper.AttrAttrGroupRelationMapper;
import com.jia.product.service.AttrAttrGroupRelationService;
import com.jia.product.vo.AttrGroupRelationVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 属性&属性分组关联(AttrAttrGroupRelation)表服务实现类
 *
 * @author makejava
 * @since 2025-07-08 18:15:25
 */
@Service("attrAttrGroupRelationService")
public class AttrAttrGroupRelationServiceImpl extends
        ServiceImpl<AttrAttrGroupRelationMapper, AttrAttrGroupRelation>
        implements AttrAttrGroupRelationService {

    @Override
    public void deleteBatch(List<AttrGroupRelationVo> attrRelationIds) {
        this.baseMapper.deleteByList(attrRelationIds);
    }

    @Override
    public void insertBatch(List<AttrGroupRelationVo> attrRelationIds) {
        List<AttrAttrGroupRelation> collect = attrRelationIds.stream().map((vo) -> {
            AttrAttrGroupRelation attrAttrGroupRelation = new AttrAttrGroupRelation();
            BeanUtils.copyProperties(vo, attrAttrGroupRelation);
            return attrAttrGroupRelation;
        }).collect(Collectors.toList());
        this.baseMapper.insertBatch(collect);
    }

}

